package com.atguigu.gulimall.product.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.gulimall.product.entity.SpuSaleAttrValue;
import com.atguigu.gulimall.product.service.SpuSaleAttrValueService;
import com.atguigu.gulimall.product.mapper.SpuSaleAttrValueMapper;
import org.springframework.stereotype.Service;

/**
 * @author nicc
 * @description 针对表【spu_sale_attr_value(spu销售属性值)】的数据库操作Service实现
 * @createDate 2022-09-26 18:25:42
 */
@Service
public class SpuSaleAttrValueServiceImpl extends ServiceImpl<SpuSaleAttrValueMapper, SpuSaleAttrValue>
        implements SpuSaleAttrValueService{

    @Override
    public Long getId(Long spuId, String saleAttrName) {
        QueryWrapper<SpuSaleAttrValue> queryWrapper = new QueryWrapper<>();

        queryWrapper.eq("spu_id", spuId);
        queryWrapper.eq("sale_attr_value_name", saleAttrName);

        SpuSaleAttrValue value = baseMapper.selectOne(queryWrapper);

        return value.getId();
    }
}